*     trig test
*                  2        2
*     calculate sin  x + cos  x for -90 <= x <= 90
*
*     the maximum error is saved and printed after 'iters'
*     calculations in real*4 and real*8

      program     trig test

      real*4      x,   sx,   cx,   error,   radians
      real*8      d x, d sx, d cx, d error, d radians
      integer*2   iters
      integer*2   max iters
      integer*2   i
      integer*2   t1 (4), t2 (4)

      radians (i)   = float (i)*0.01745 32925
      d radians (i) = float (i)*0.01745 32925 19943 D 0

      write (*, *)' iters: '
      read  (*, *) max iters
      call time (t1)
      do 200 iters = 1, max iters
         error = 0.0
         do 100 i = -90, 90
            x   = radians (i)
            sx  = sin (x)
            cx  = cos (x)
            error = max (error, abs (1.0 - sx**2 - cx**2))
100         continue
200      continue
      call etime (t2, t1, max iters)
      write (*, *)'real*4 error', error
      write (*, *)' '

      call time (t1)
      do 400 iters = 1, max iters
         d error = 0.0
         do 300 i = -90, 90
            d x  = d radians (i)
            d sx = sin (d x)
            d cx = cos (d x)
            d error = max (d error, abs (1.0 - d sx**2 - d cx**2))
300         continue
400      continue

      call etime (t2, t1, max iters)
      write (*, *) 'real*8 error', d error
      end
